package zzps.exeed.web;

import zzps.exeed.web.http.HttpMethod;
import zzps.exeed.web.http.MimeType;
import zzps.exeed.web.transformer.InputOutputTransformerManager;

import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
import java.net.URL;

public interface Context {

    Object request();
    Object response();

    //------------------request-----------//
    String path();
    URL url();
    URI uri();
    HttpMethod method();
    String getParameter(String name);
    InputStream getInputStream();
    String getContentType();
    //------------------request-----------//
    //------------------response-----------//
    OutputStream getOutputStream();
    void status(int status);
    void setContentType(String type);
    //------------------response-----------//

    default void output(Object object){
        setContentType(MimeType.APPLICATION_JSON.getValue());
        InputOutputTransformerManager.get().json().output(object,this);
    }
}
